<template>
  <div>
    <van-dialog
      v-model="show"
      :show-cancel-button="asd"
      :showConfirmButton="showConfirmButton"
      closeOnClickOverlay
    >
      <div class="dialog_title">
        <div class="dialog_title_item">免费接送看房</div>
        <div style="margin:0 2px;">+</div>
        <div class="dialog_title_item">免费接送看房</div>
        <div style="margin:0 2px;">+</div>
        <div class="dialog_title_item">免费接送看房</div>
      </div>
      <div class="content">报名成功后，工作人员会稍后跟您联系</div>
      <input class="inp" type="text" disabled :placeholder="housesName" />
      <input class="inp" type="text" v-model="inpName" placeholder="请输入您的姓名" />
      <input class="inp" type="text" v-model="inpPhone" placeholder="请输入您的手机号码" />
      <div class="subBtn" @click="subBtn">立即报名</div>
      <div style="padding-bottom:25px">
        <div class="youhuiMessage_warp">
          <div class="youhuiMessage_tit">购房后享受的三大优惠</div>
          <div>一、凡购房成功即赠送大礼包</div>
          <div>二、购房成功后享受机票报销</div>
          <div>三、购房成功后享受十年免费接送服务</div>
        </div>
      </div>
    </van-dialog>
  </div>
</template>

<script>
import { Dialog } from "vant";
import * as API from "@/http/common/api";
export default {
  name: "baoming",
  data() {
    return {
      show: false, //报名弹窗
      asd: false,
      showConfirmButton: false,
      inpName: "",
      inpPhone: ""
    };
  },
  props: ["housesName", "clientGjProject",'groupBuyingName'],
  methods: {
    //立即报名
    subBtn() {
      if (!this.inpName) {
        this.$toast({ message: "请输入姓名" });
        return;
      }
      if (!this.isLegal(this.inpPhone)) {
        this.$toast({ message: "手机号有误" });
        return;
      }
      console.log(22222222222)
      this.$http(API.addClient, {
        type: "POST",
        params: {
          clientGjProject: this.clientGjProject, 
          clientName: this.inpName,
          clientTel: this.inpPhone,
          groupBuyingName: this.groupBuyingName
        }
      }).then(res => {
        if (res.data.code == 0) {
          this.$toast({ message: "提交成功" });
          this.hasOpen(); //关闭弹窗
        }
      });
    },
        // 手机号
    isLegal() {
      var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(16[0-9]{1})|(19[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\d{8})$/;
      if (!myreg.test(this.inpPhone)) {
        return false;
      } else {
        return true;
      }
    },
    hasOpen() {
      this.show = !this.show ;
    }
  },
  mounted() {},
  components: {
    [Dialog.Component.name]: Dialog.Component
  }
};
</script>

<style scoped lang='less'>
.van-dialog {
  font-size: 28px;
  width: 580px;
  padding: 1px 51px 1px 51px;
  box-sizing: border-box;
  border-radius: 28px;
}

.content {
  margin-top: 20px;
  font-size: 26px;
  text-align: center;
}
.inp {
  width: 484px;
  height: 60px;
  background: #fff;
  border-radius: 4px;
  border: 2px solid #999999;
  margin-top: 30px;
  padding-left: 20px;
  box-sizing: border-box;
}
.http {
  color: #666;
  text-align: center;
  margin-top: 20px;
}
.subBtn {
  width: 484px;
  height: 60px;
  background: #48bf01;
  font-size: 34px;
  color: #fff;
  text-align: center;
  line-height: 60px;
  border-radius: 5px;
  margin-top: 46px;
}
.footer {
  display: flex;
  align-items: center;
  margin-top: 20px;
  justify-content: center;
  color: #48bf01;
}
.dialog_title {
  display: flex;
  justify-content: center;
  align-items: center;
  color: #48bf01;
  padding-top: 30px;
  .dialog_title_item {
    width: 150px;
    height: 90px;
    font-size: 30px;
    border: #48bf01 2px dashed;
    padding: 0 0 0 8px;
    box-sizing: border-box;
    line-height: 40px;
  }
}
.youhuiMessage_warp {
  width: 480px;
  height: 200px;
  border: 2px #48bf01 dashed;
  color: #48bf01;
  font-size: 26px;
  padding-left: 20px;
  margin-top: 20px;
  div {
    margin-bottom: 8px;
  }
  box-sizing: border-box;
  .youhuiMessage_tit {
    text-align: center;
    margin-bottom: 10px;
    font-size: 28px;
    font-weight: bold;
  }
}
</style>
